fix(tabs): preserve active header during restore#2141
Conversation
Greptile SummaryThis PR fixes a bug where restoring multiple tabs caused the active file header to be overwritten with the name of subsequently-added (non-active) files. The one-line guard ensures
Confidence Score: 5/5Safe to merge — the change is a minimal, targeted guard that only prevents a silent header overwrite during session restore without touching any other code path. The fix is a single conditional wrapping one assignment in addFile. All downstream header-update paths (switchFile, the filename setter) remain untouched. Edge cases — fresh start with no active file, background-open with render: false, and plugin-triggered opens — are all handled correctly by existing code that runs after addFile. No regressions are introduced. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant RF as restoreFiles.js
participant EF as EditorFile(constructor)
participant AM as addFile()
participant MK as makeActive/switchFile()
RF->>EF: "new EditorFile(file0, {render:true})"
EF->>AM: addFile(file0) — activeFile is null
AM-->>AM: "$header.text = file0.name"
EF->>MK: render() → makeActive()
MK-->>MK: "manager.activeFile = file0, $header.text = file0.filename"
RF->>EF: "new EditorFile(file1, {render:false})"
EF->>AM: "addFile(file1) — activeFile = file0"
Note over AM: OLD: $header.text = file1.name (bug)<br/>NEW: guard skips update
RF->>EF: "new EditorFile(file2, {render:false})"
EF->>AM: "addFile(file2) — activeFile = file0"
Note over AM: NEW: guard skips update, header stays = file0.filename
Reviews (1): Last reviewed commit: "fix(tabs): preserve active header during..." | Re-trigger Greptile |
This was the issue : 👇
